/*
 * Copyright (c) 2023, 2023,yzc.cn All rights reserved.
 *
 */
package cn.yzc.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * <p>Project: redis - RedisUtils</p>
 * <p>Powered by yzc On 2023-12-14 08:53:49</p>
 * <p>描述：<p>
 *
 * @author yzc [yzc0415@126.com]
 * @version 1.0
 * @since 17
 */
@Component
public class RedisUtils {

    @Autowired
    RedisTemplate<String,Object> redisTemplate;

    public void set(String key,Object values){
        redisTemplate.opsForValue().set(key, values);
    }

    public void set(String key, Object values,Long timeout){
        redisTemplate.opsForValue().set(key,values,timeout, TimeUnit.SECONDS);
    }

    public Object get(String key){
        return redisTemplate.opsForValue().get(key);
    }
}
